home *** CD-ROM | disk | FTP | other *** search
/ MacFormat España 19 / macformat_19.iso / Shareware / Developers / N Game Library1.1.0E(ppc) / Audio Sample(PPC) / Audio_Sample(PPC).c < prev   
Encoding:
C/C++ Source or Header  |  1996-06-23  |  1.7 KB  |  78 lines  |  [TEXT/CWIE]

  1. /*============================================================
  2.  
  3.                   N-Music/Sound Sample program
  4.                     
  5. ============================================================*/
  6.  
  7. #include            "N_Library.h"
  8.  
  9. void             DoEvent            (EventRecord *eventPtr);
  10. void             DoError            (Str255 errorString);
  11. WindowPtr     CreateWindow         (Str255 name);
  12.  
  13.  
  14. #define        WindowSizeX        320
  15. #define        WindowSizeY        240
  16.  
  17. short        NewWindowX;
  18. short        NewWindowY;
  19.  
  20. short        Data_Rsrc = 0;
  21. long            wait;
  22.  
  23. short        Sounds[] = { 1000,1001,0 };                    //'SND'resource id
  24. short        Music1[] = { 1000,1001,-1 };                    //music 1 block (1000,1001,1001,1001,,,,)
  25.  
  26. void main(void)
  27. {
  28.     WindowPtr    window;
  29.  
  30.     ToolboxInit();
  31.     ColorCheck();
  32.     window = CreateWindow("\pN Game Library <Audio Sample>");
  33.  
  34.     Open_Resource_File(128,1,&Data_Rsrc);
  35.     N_Pict_Draw(128,0,0,(GrafPtr)window,true);
  36.     N_Sound_Load(&Sounds[0]);                                //open sound channels and read 'SND'
  37.     N_Music_Set(1,&Music1[0]);                                //set up music1 blocks
  38.     N_Music_Play(1);                                        //play music1
  39.  
  40.     do
  41.     {
  42.         N_Music_Loop();
  43.     }
  44.     while (!Button());
  45.  
  46.     N_Music_Out(180);                                        //Fade out
  47.     do
  48.     {
  49.         N_Music_Loop();
  50.     }
  51.     while (FO_Flag == true);
  52.  
  53.     ColorRevert();
  54.     N_Sound_Close();                                        //close sounds channels
  55.  
  56. }
  57.  
  58. WindowPtr CreateWindow (Str255 name)
  59. {
  60.     WindowPtr    window;
  61.     short        centerX,centerY;
  62.     short        windowWidth,windowHeight;
  63.  
  64.  
  65.     window = GetNewWindow (128,nil,(WindowPtr)-1L );
  66.     centerX  = (qd.screenBits.bounds.right -qd.screenBits.bounds.left)/2;
  67.     centerY  = (qd.screenBits.bounds.bottom -qd.screenBits.bounds.top)/2;
  68.     SetWTitle(window,name);
  69.     MoveWindow(window,NewWindowX=centerX-(WindowSizeX/2),NewWindowY=centerY-(WindowSizeY/2),false);
  70.     SizeWindow(window,WindowSizeX,WindowSizeY,TRUE);
  71.  
  72.     ShowWindow(window);
  73.     SetPort((GrafPtr)window );
  74.     return (WindowPtr)window;
  75. }
  76.     
  77.  
  78.